﻿{extend name="common/base"}
{block name="title"}商品详情页{/block}

<body>
	
{block name="content"}
	<!-- settings -->
	<div class="segments-page">
		<div class="container">
			<div class="settings">
				<div class="pages-title">
					<h3>修改收货地址</h3>
				</div>
				<form action="{:Url('user/update')}?id={$list.id}" method="POST">
					<input type="text" value="{$list.shouhuo_name}" name="shouhuo_name">
					<input type="text" value="{$list.shouhuo_tell}" name="shouhuo_tell">
					<input type="text" value="{$list.shouhuo_address}" name="shouhuo_address">
					<button class="button" type="submit">保存修改</button>
				</form>
				{if($list.address_id!=$list.id)}
				<button class="button" onclick="morenadd(this)">设置默认地址</button>
				{/if}
				<input type="hidden" value="{$list.id}">
				<a href="{:Url('user/delete')}?id={$list.id}"><button class="button">删除这个地址</button></a>
			</div>
		</div>
	</div>
	<!-- end settings -->
	<div id="showmsg" style="display:none;width: 200px;border-radius: 10px;background: rgba(0,0,0,0.6);height: 100px;position: fixed;top: 50%;left:50%;margin-left: -100px;color: #FFF;text-align: center;line-height: 100px;font-size: 18px;z-index:999;">
	</div>
{/block}

{block name="footjs"}
<script>
	function morenadd(obj){
		var address_id = $(obj).next().val();
		var user_id = "{:session('id')}";
		$.ajax({
			url:"{:Url('index/user/addmoren')}",
			type:"post",
			data:{address_id:address_id,user_id:user_id},
			dataType:"json",
			success:function(data){
				console.log(data);
				$('#showmsg').html(data.msg);
                $('#showmsg').fadeIn('slow',function(){
                    setTimeout(function(){
                        $('#showmsg').fadeOut();
                    },1000);
                });
			}
		})
	}
</script>
{/block}
